/*
 * @Author: chengsl
 * @Date: 2021-12-21 14:32:56
 * @LastEditors: chengsl
 * @LastEditTime: 2023-05-08 17:43:15
 * @Description: file content
 */
import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layout/index'

export const constantRouterMap = [
  {
    path: '/login',
    meta: { title: '登录', noCache: true },
    component: () => import('@/views/login'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/features/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/features/401'),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    // hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/features/redirect')
      }
    ]
  },
  {
    path: '/',
    redirect: '/dashboard',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/home'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'index', affix: true, noCache: true }
      }
    ]
  }
]
  
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes: constantRouterMap,
  strict: false,
  scrollBehavior: () => ({ left: 0, top: 0 })
})

router.appName = 'uduhs'

/**
 * @description: 重置 router
 */
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
